package com.magic.zhixin.config;

import com.magic.zhixin.handler.DelayTask.DelayTaskClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 项目启动就会执行，初始化的任务可以放这里
 */
@Component
@Slf4j
public class AutoStart implements /*CommandLineRunner*/ApplicationRunner {
    @Autowired
    private DelayTaskClient delayTaskClient;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        try {
        System.out.println("This will be execute when the project was started!");
        log.info("==========项目启动触发，初始化可放这里=======");
        delayTaskClient.start();//启动定时任务
//        initAddRound();
        } catch (Exception e) {
            e.printStackTrace();
            log.error("项目启动初始化失败，原因{}",e.getMessage());
            log.error("{}",e);
//            throw e;
        }
    }


}
